from django.db import models


class AuditLog(models.Model):
    """
    日志记录
    """
    user = models.CharField("UserProfile", verbose_name="堡垒机账号", blank=True, null=True)

    host_to_remote_user = models.CharField("HostToRemoteUser", verbose_name="主机账号", blank=True, null=True)

    log_type_choices = (
        (0, 'login'),
        (1, 'cmd'),
        (2, 'logout'),
    )

    log_type = models.SmallIntegerField(choices=log_type_choices)
    content = models.CharField(max_length=1024, blank=True, null=True)
    datetime = models.DateTimeField(auto_now_add=True, blank=True, null=True)

    def __str__(self):
        return f'{self.user} {self.host_to_remote_user} {self.content}'
